#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll read(){
    ll f=1,x=0;
    char c;
    while (c=getchar()){
        if (c>='0'&&c<='9') x=x*10+c-'0';
        else if (c=='-') f=-1;
        else break;
    }
    return x*f;
}
ll T,ans,n;
ll a[200005];
bool c[200005];
void dfs(ll deep){
    if (deep>n){
        ll s=0;
        for (ll i=1;i<=n;i++)
            for (ll j=i-1;j>=1;j--)
                if (c[j]==c[i]&&a[j]==a[i]){
                    s+=a[j];
                    break;
                }
        ans=max(ans,s);
        return;
    }
    c[deep]=1;
    dfs(deep+1);
    c[deep]=0;
    dfs(deep+1);
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    T=read();
    while(T--){
        n=read();
        for (ll i=1;i<=n;i++) a[i]=read();
        dfs(1);
        cout<<ans<<'\n';
        ans=0;
    }
    return 0;
}
